package com.framwork;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.DefaultResourceLoader;

/**
 * @author ysw
 * @create 2019-07-31 17:20
 * @descreption
 **/
//@ImportResource(locations = {"classpath:spring.xml"})
public class MyIocApplication {

    public static void main(String[] args) {
//        //注册中心
//        BeanDefinitionRegistry regitster = new SimpleBeanDefinitionRegistry();
//        //读取器
//        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(regitster);
//
//        //资源读取器
//        DefaultResourceLoader loader = new DefaultResourceLoader();
//        reader.loadBeanDefinitions(loader.getResource("classpath:spring.xml"));
//        System.out.println(regitster.getBeanDefinition("diver").getBeanClassName());

        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
        reader.setResourceLoader(new DefaultResourceLoader());
        reader.loadBeanDefinitions("spring.xml");
        factory.getBean("diver");
//        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:spring.xml");
//        context.getBean("diver");
    }


}